home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1996-02-22 | 7.1 KB | 194 lines | [TEXT/3PRM] |
- implementation module dialogs;
-
- import mac_types;
-
- :: ProcPtr :== Int;
-
- // Initialization
-
- InitDialogs :: !ProcPtr !Toolbox -> Toolbox;
- InitDialogs resumeProc t = code (resumeProc=L,t=U)(z=Z){
- instruction 0xA97B
- };
-
- // Creating and Disposing of Dialogs
-
- NewDialog :: !Ptr !Rect !{#Char} !Bool !Int !WindowPtr !Bool !Int !Handle !Toolbox -> (!DialogPtr, !Toolbox);
- NewDialog dStorage (left,top,right,bottom) title visible procID behind goAwayFlag refCon items t
- = code (right=W,bottom=W,left=W,top=W,dStorage=R4L,title=O8S,visible=W,procID=W,
- behind=L,goAwayFlag=W,refCon=L,items=L,t=U) (dialog=L,z=I8Z)
- {
- instruction 0xA97D || _NewDialog
- };
-
- NewCDialog :: !Ptr !Rect !{#Char} !Bool !Int !WindowPtr !Bool !Int !Handle !Toolbox -> (!DialogPtr,!Toolbox);
- NewCDialog dStorage (left,top,right,bottom) title visible procID behind goAwayFlag refCon items t
- = code (right=W,bottom=W,left=W,top=W,dStorage=R4L,title=O8S,visible=W,procID=W,
- behind=L,goAwayFlag=W,refCon=L,items=L,t=U) (dialog=L,z=I8Z)
- {
- instruction 0xAA4B || _NewCDialog
- };
-
- CloseDialog :: !DialogPtr !Toolbox -> Toolbox;
- CloseDialog theDialog t = code (theDialog=L,t=U)(z=Z){
- instruction 0xA97D || _CloseDialog
- };
-
- DisposDialog :: !DialogPtr !Toolbox -> Toolbox;
- DisposDialog theDialog t = code (theDialog=L,t=U)(z=Z){
- instruction 0xA983
- };
-
- // Handling Dialog Events
-
- ModalDialog :: !ProcPtr !DialogPtr !Toolbox -> (!Int,!Toolbox);
- ModalDialog filterProc dialog t = code (filterProc=R2L,dialog=O4U,t=U)(itemHit=W,z=Z){
- instruction 0xA991 || _ModalDialog
- };
-
- IsDialogEvent :: !(!Int,!Int,!Int,!Int,!Int,!Int) !Toolbox -> (!Bool,!Toolbox);
- IsDialogEvent event tb = IsDialogEvent1 event;
-
- IsDialogEvent1 :: !(!Int,!Int,!Int,!Int,!Int,!Int) -> (!Bool,!Toolbox);
- IsDialogEvent1 (what,message,when,h,v,modifiers) = code (modifiers=W,h=W,v=W,when=L,message=L,what=W)(result=D1,z=I16Z){
- instruction 0x558F || subq.l #2,sp
- instruction 0x486F 0x0002 || pea 2(sp)
- instruction 0xA97F
- instruction 0x7001 || moveq #1,d0
- instruction 0xC01F || and.b (sp)+,d0
- instruction 0x4480 || neg.l d0
- instruction 0x2200 || move.l d0,d1
- };
-
- DialogSelect :: !(!Int,!Int,!Int,!Int,!Int,!Int) !Toolbox -> (!Bool,!DialogPtr,!Int,!Toolbox);
- DialogSelect event tb
- = (b, dPtr, itemNr, tb);
- where{
- (b, dPtr, itemNr) = DialogSelect1 event};
-
- DialogSelect1 :: !(!Int,!Int,!Int,!Int,!Int,!Int) -> (!Bool,!DialogPtr,!Int);
- DialogSelect1 (what,message,when,h,v,modifiers) = code (modifiers=W,h=W,v=W,when=L,message=L,what=W)(result=D2,theDialog=D1,itemHit=D0){
- instruction 0x518F || subq.l #8,sp
- instruction 0x486F 0x0008 || pea 8(sp)
- instruction 0x486F 0x0006 || pea 6(sp)
- instruction 0x486F 0x000E || pea 14(sp)
- instruction 0xA980
- instruction 0x7401 || moveq #1,d2
- instruction 0xC41F || and.b (sp)+,d2
- instruction 0x4482 || neg.l d2
- instruction 0x221F || move.l (sp)+,d1
- instruction 0x301F || move (sp)+,d0
- instruction 0x48C0 || ext.l d0
- instruction 0x4FEF 0x0010 || lea 16(sp),sp
- };
-
- // Invoking Alerts
-
- // Manipulating Items in Dialogs and Alerts
-
- GetDItem :: !DialogPtr !Int !Toolbox -> (!Int,!Handle,!Rect,!Toolbox);
- GetDItem theDialog itemNo tb
- = (itemType, item, rect, NewToolbox);
- where{
- (itemType, item, rect) = GetDItem1 theDialog itemNo tb};
-
- GetDItem1 :: !DialogPtr !Int !Toolbox -> (!Int,!Handle,!Rect);
- GetDItem1 theDialog itemNo t = code (theDialog=R14L,itemNo=W,t=U)(itemType=D5,item=D4,left=D3,top=D2,right=D1,bottom=D0){
- instruction 0x486F 0x0006 || pea 6(sp)
- instruction 0x486F 0x000C || pea 12(sp)
- instruction 0x486F 0x0014 || pea 20(sp)
- instruction 0xA98D || _GetDItem
- instruction 0x3A1F || move (sp)+,d5
- instruction 0x48C5 || ext.l d5
- instruction 0x281F || move.l (sp)+,d4
- instruction 0x4C9F 0x000F || movem (sp)+,d0-d3
- instruction 0xC340 || exg d1,d0
- instruction 0xC742 || exg d3,d2
- };
-
- SetIText :: !Handle !{#Char} !Toolbox -> Toolbox;
- SetIText item text t = code (item=L,text=S,t=U)(z=Z){
- instruction 0xA98F
- };
-
- GetIText :: !Handle !{#Char} !Toolbox -> (!{#Char},!Toolbox);
- GetIText item text tb = (GetIText1 item text tb, NewToolbox);
-
- GetIText1 :: !Handle !{#Char} !Toolbox -> {#Char};
- GetIText1 item text t = code (item=L,text=A0,t=U)(new_text=A0){
- instruction 0x2808 || move.l a0,d4
- instruction 0x42A8 0x0004 || clr.l 4(a0)
- instruction 0x4868 0x0007 || pea 7(a0)
- instruction 0xA990 || _GetIText
- instruction 0x2044 || move.l d4,a0
- };
-
- SelIText :: !DialogPtr !Int !Int !Int !Toolbox -> Toolbox;
- SelIText theDialog itemNo strtSel endSel t = code (theDialog=L,itemNo=W,strtSel=W,endSel=W,t=U)(z=Z){
- instruction 0xA97E || _SelIText
- };
-
- OutlineButtonFunction :: ProcPtr;
- OutlineButtonFunction = code ()(function_address=D0){
- instruction 0x41FA 0x0006 | lea l1(pc),a0
- instruction 0x2008 | move.l a0,d0
- instruction 0x6040 | bra.s l2
- instruction 0x201F | l1: move.l (sp)+,d0
- instruction 0x321F | move.w (sp)+,d1
- instruction 0x241F | move.l (sp)+,d2
- instruction 0x2F00 | move.l d0,-(sp)
- instruction 0x4FEF 0xFFF2 | lea -14(sp),sp
- instruction 0x2F02 | move.l d2,-(sp)
- instruction 0x3F01 | move.w d1,-(sp)
- instruction 0x486F 0x0006 | pea 6(sp)
- instruction 0x486F 0x000C | pea 12(sp)
- instruction 0x486F 0x0014 | pea 20(sp)
- instruction 0xA98D | _GetDItem
- instruction 0x5C8F | addq.l #6,sp
- instruction 0x2F3C 0x0003 0x0003 | move.l #$00030003,-(sp)
- instruction 0xA89B | _PenSize
- instruction 0x2F0F | move.l sp,-(sp)
- instruction 0x2F3C 0xFFFC 0xFFFC | move.l #$fffcfffc,-(sp)
- instruction 0xA8A9 | _InsetRect
- instruction 0x2F0F | move.l sp,-(sp)
- instruction 0x2F3C 0x0010 0x0010 | move.l #$00100010,-(sp)
- instruction 0xA8B0 | _FrameRoundRect
- instruction 0x508F | addq.l #8,sp
- instruction 0x4E75 | rts
- | l2:
- };
-
- DisposeRoutineDescriptor :: !ProcPtr !Toolbox -> Toolbox;
- DisposeRoutineDescriptor p t = t;
-
- DialogFilterFunction :: ProcPtr;
- DialogFilterFunction = code ()(function_address=D0){
- instruction 0x41FA 0x0006 | lea l2(pc),a0
- instruction 0x2008 | move.l a0,d0
- instruction 0x6046 | bra.s l3:
- instruction 0x2017 | l2: move.l (sp),d0
- instruction 0x508F | addq.l #8,sp
- instruction 0x205F | move.l (sp)+,a0
- instruction 0x2257 | move.l (sp),a1
- instruction 0x2E80 | move.l d0,(sp)
- instruction 0x0C50 0x0006 | cmp.w #6,(a0)
- instruction 0x670E | beq.s update
- instruction 0x0C50 0x0003 | cmp.w #3,(a0)
- instruction 0x6714 | beq.s key_down
- instruction 0x4251 | ret_false: clr.w (a1)
- instruction 0x426F 0x0004 | clr.w 4(sp)
- instruction 0x4E75 | rts
- instruction 0x32BC 0xFFFF | update: move.w #-1,(a1)
- instruction 0x3F7C 0xFFFF 0x0004 | move.w #-1,4(sp)
- instruction 0x4E75 | rts
- instruction 0x1028 0x0005 | key_down: move.b 5(a0),d0
- instruction 0x0C00 0x000D | cmp.b #13,d0
- instruction 0x6706 | beq.s return_key
- instruction 0x0C00 0x0003 | cmp.b #3,d0
- instruction 0x66DC | bne.s ret_false
- instruction 0x32BC 0x0001 | return_key: move.w #1,(a1)
- instruction 0x3F7C 0xFFFF 0x0004 | move.w #-1,4(sp)
- instruction 0x4E75 | rts
- | l3:
- };
-